#ifndef TABARRAY_H
#define TABARRAY_H

#include <QObject>
#include "tabitem.h"

class TabArray : public QObject
{
	Q_OBJECT
public:
	explicit TabArray(QObject *parent = 0);
	inline TabItem *newTab(TabItem *tab) {
		m_array->append(tab);
		return tab;
	}
	inline TabItem *tabAt(unsigned index) { return m_array->at(index); }
	inline void changeTab(int index, BookmarkItem *bookmark) { m_array->at(index)->change(bookmark); }
	inline void deleteTab(int index) { m_array->at(index)->deleteLater(); m_array->remove(index); updateArray(); }
	~TabArray();
private:
	inline void updateArray(void) {
		for(int i = 0; i < m_array->size(); i++)
			m_array->at(i)->setTabId(i);
	}
	QVector<TabItem*> *m_array;
};

#endif // TABARRAY_H
